home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / CLISRV / BOOKSALE / CLIENT / FRMCOGS.FRM (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1996-09-20  |  17.6 KB  |  544 lines

  1. VERSION 5.00
  2. Begin VB.Form frmCogs 
  3.    BorderStyle     =   3  'Fixed Dialog
  4.    Caption         =   "COGS Options"
  5.    ClientHeight    =   2550
  6.    ClientLeft      =   705
  7.    ClientTop       =   3975
  8.    ClientWidth     =   6900
  9.    ClipControls    =   0   'False
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    MinButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   2550
  15.    ScaleWidth      =   6900
  16.    StartUpPosition =   2  'CenterScreen
  17.    WhatsThisHelp   =   -1  'True
  18.    Begin VB.CommandButton Command1 
  19.       Caption         =   "&Save"
  20.       Default         =   -1  'True
  21.       Height          =   420
  22.       Index           =   0
  23.       Left            =   5550
  24.       TabIndex        =   13
  25.       Top             =   1650
  26.       Width           =   1215
  27.    End
  28.    Begin VB.CommandButton Command1 
  29.       Caption         =   "&Help"
  30.       Height          =   420
  31.       Index           =   1
  32.       Left            =   5550
  33.       TabIndex        =   12
  34.       Top             =   705
  35.       Width           =   1215
  36.    End
  37.    Begin VB.CommandButton Command1 
  38.       Caption         =   "&Cancel"
  39.       Height          =   420
  40.       Index           =   2
  41.       Left            =   5550
  42.       TabIndex        =   11
  43.       Top             =   210
  44.       Width           =   1215
  45.    End
  46.    Begin VB.Frame Frame3 
  47.       Caption         =   "Paper Type"
  48.       Height          =   2340
  49.       Left            =   1965
  50.       TabIndex        =   6
  51.       Top             =   120
  52.       Width           =   1395
  53.       Begin VB.OptionButton optPaperGrade 
  54.          Caption         =   "Grade 2"
  55.          Height          =   285
  56.          Index           =   1
  57.          Left            =   150
  58.          TabIndex        =   10
  59.          Top             =   690
  60.          Width           =   1215
  61.       End
  62.       Begin VB.OptionButton optPaperGrade 
  63.          Caption         =   "Grade 3"
  64.          Height          =   285
  65.          Index           =   2
  66.          Left            =   150
  67.          TabIndex        =   9
  68.          Top             =   1050
  69.          Width           =   1215
  70.       End
  71.       Begin VB.OptionButton optPaperGrade 
  72.          Caption         =   "Grade 4"
  73.          Height          =   285
  74.          Index           =   3
  75.          Left            =   150
  76.          TabIndex        =   8
  77.          Top             =   1410
  78.          Width           =   1215
  79.       End
  80.       Begin VB.OptionButton optPaperGrade 
  81.          Caption         =   "Grade 1"
  82.          Height          =   285
  83.          Index           =   0
  84.          Left            =   150
  85.          TabIndex        =   7
  86.          Top             =   330
  87.          Value           =   -1  'True
  88.          Width           =   1215
  89.       End
  90.    End
  91.    Begin VB.Frame Frame2 
  92.       Caption         =   "Picture Colors"
  93.       Height          =   1125
  94.       Left            =   105
  95.       TabIndex        =   3
  96.       Top             =   1335
  97.       Width           =   1680
  98.       Begin VB.OptionButton optPicColor 
  99.          Caption         =   "Color"
  100.          Height          =   285
  101.          Index           =   1
  102.          Left            =   120
  103.          TabIndex        =   5
  104.          Top             =   690
  105.          Width           =   1500
  106.       End
  107.       Begin VB.OptionButton optPicColor 
  108.          Caption         =   "Black && White"
  109.          Height          =   285
  110.          Index           =   0
  111.          Left            =   120
  112.          TabIndex        =   4
  113.          Top             =   345
  114.          Value           =   -1  'True
  115.          Width           =   1500
  116.       End
  117.    End
  118.    Begin VB.Frame Frame1 
  119.       Caption         =   "Binding Type"
  120.       Height          =   1125
  121.       Left            =   105
  122.       TabIndex        =   0
  123.       Top             =   120
  124.       Width           =   1680
  125.       Begin VB.OptionButton optBinding 
  126.          Caption         =   "Paper Back"
  127.          Height          =   285
  128.          Index           =   1
  129.          Left            =   140
  130.          TabIndex        =   2
  131.          Top             =   600
  132.          Width           =   1215
  133.       End
  134.       Begin VB.OptionButton optBinding 
  135.          Caption         =   "Hard Cover"
  136.          Height          =   285
  137.          Index           =   0
  138.          Left            =   140
  139.          TabIndex        =   1
  140.          Top             =   300
  141.          Value           =   -1  'True
  142.          Width           =   1215
  143.       End
  144.    End
  145.    Begin VB.Frame FrameConverted 
  146.       BackColor       =   &H00C0C0C0&
  147.       Height          =   2355
  148.       Left            =   3465
  149.       TabIndex        =   14
  150.       Top             =   90
  151.       Width           =   1905
  152.       Begin VB.Label Label1 
  153.          Alignment       =   1  'Right Justify
  154.          AutoSize        =   -1  'True
  155.          BackStyle       =   0  'Transparent
  156.          Caption         =   "+"
  157.          ForeColor       =   &H00800000&
  158.          Height          =   195
  159.          Index           =   10
  160.          Left            =   1725
  161.          TabIndex        =   32
  162.          Top             =   1455
  163.          Width           =   90
  164.       End
  165.       Begin VB.Label lblCost 
  166.          Alignment       =   1  'Right Justify
  167.          BackStyle       =   0  'Transparent
  168.          ForeColor       =   &H00800000&
  169.          Height          =   195
  170.          Index           =   6
  171.          Left            =   1125
  172.          TabIndex        =   31
  173.          Top             =   1755
  174.          Width           =   585
  175.       End
  176.       Begin VB.Label Label1 
  177.          Alignment       =   1  'Right Justify
  178.          BackStyle       =   0  'Transparent
  179.          Caption         =   "Unit Cost"
  180.          BeginProperty Font 
  181.             Name            =   "MS Sans Serif"
  182.             Size            =   8.25
  183.             Charset         =   0
  184.             Weight          =   700
  185.             Underline       =   0   'False
  186.             Italic          =   0   'False
  187.             Strikethrough   =   0   'False
  188.          EndProperty
  189.          ForeColor       =   &H00800000&
  190.          Height          =   255
  191.          Index           =   9
  192.          Left            =   60
  193.          TabIndex        =   30
  194.          Top             =   1755
  195.          Width           =   1005
  196.       End
  197.       Begin VB.Label Label1 
  198.          Alignment       =   1  'Right Justify
  199.          AutoSize        =   -1  'True
  200.          BackStyle       =   0  'Transparent
  201.          Caption         =   "___________________"
  202.          ForeColor       =   &H00800000&
  203.          Height          =   195
  204.          Index           =   8
  205.          Left            =   105
  206.          TabIndex        =   29
  207.          Top             =   1515
  208.          Width           =   1710
  209.       End
  210.       Begin VB.Label lblCost 
  211.          Alignment       =   1  'Right Justify
  212.          BackStyle       =   0  'Transparent
  213.          ForeColor       =   &H00800000&
  214.          Height          =   195
  215.          Index           =   5
  216.          Left            =   1125
  217.          TabIndex        =   28
  218.          Top             =   1455
  219.          Width           =   585
  220.       End
  221.       Begin VB.Label Label1 
  222.          Alignment       =   1  'Right Justify
  223.          BackStyle       =   0  'Transparent
  224.          Caption         =   "Binding Type"
  225.          ForeColor       =   &H00800000&
  226.          Height          =   255
  227.          Index           =   7
  228.          Left            =   60
  229.          TabIndex        =   27
  230.          Top             =   1455
  231.          Width           =   1005
  232.       End
  233.       Begin VB.Label lblCost 
  234.          Alignment       =   1  'Right Justify
  235.          BackStyle       =   0  'Transparent
  236.          ForeColor       =   &H00800000&
  237.          Height          =   195
  238.          Index           =   4
  239.          Left            =   1125
  240.          TabIndex        =   26
  241.          Top             =   1245
  242.          Width           =   585
  243.       End
  244.       Begin VB.Label lblCost 
  245.          BackStyle       =   0  'Transparent
  246.          ForeColor       =   &H00800000&
  247.          Height          =   195
  248.          Index           =   3
  249.          Left            =   1125
  250.          TabIndex        =   25
  251.          Top             =   960
  252.          Width           =   555
  253.       End
  254.       Begin VB.Label lblCost 
  255.          Alignment       =   1  'Right Justify
  256.          BackStyle       =   0  'Transparent
  257.          ForeColor       =   &H00800000&
  258.          Height          =   195
  259.          Index           =   2
  260.          Left            =   1125
  261.          TabIndex        =   24
  262.          Top             =   750
  263.          Width           =   585
  264.       End
  265.       Begin VB.Label lblCost 
  266.          Alignment       =   1  'Right Justify
  267.          BackStyle       =   0  'Transparent
  268.          ForeColor       =   &H00800000&
  269.          Height          =   195
  270.          Index           =   1
  271.          Left            =   1125
  272.          TabIndex        =   23
  273.          Top             =   480
  274.          Width           =   585
  275.       End
  276.       Begin VB.Label lblCost 
  277.          Alignment       =   1  'Right Justify
  278.          BackStyle       =   0  'Transparent
  279.          ForeColor       =   &H00800000&
  280.          Height          =   195
  281.          Index           =   0
  282.          Left            =   1125
  283.          TabIndex        =   22
  284.          Top             =   270
  285.          Width           =   585
  286.       End
  287.       Begin VB.Label Label1 
  288.          Alignment       =   1  'Right Justify
  289.          AutoSize        =   -1  'True
  290.          BackStyle       =   0  'Transparent
  291.          Caption         =   "___________________"
  292.          ForeColor       =   &H00800000&
  293.          Height          =   195
  294.          Index           =   6
  295.          Left            =   105
  296.          TabIndex        =   21
  297.          Top             =   1020
  298.          Width           =   1710
  299.       End
  300.       Begin VB.Label Label1 
  301.          Alignment       =   1  'Right Justify
  302.          AutoSize        =   -1  'True
  303.          BackStyle       =   0  'Transparent
  304.          Caption         =   "*"
  305.          ForeColor       =   &H00800000&
  306.          Height          =   195
  307.          Index           =   5
  308.          Left            =   1725
  309.          TabIndex        =   20
  310.          Top             =   960
  311.          Width           =   60
  312.       End
  313.       Begin VB.Label Label1 
  314.          Alignment       =   1  'Right Justify
  315.          BackStyle       =   0  'Transparent
  316.          Caption         =   "Pages"
  317.          ForeColor       =   &H00800000&
  318.          Height          =   255
  319.          Index           =   4
  320.          Left            =   450
  321.          TabIndex        =   19
  322.          Top             =   960
  323.          Width           =   615
  324.       End
  325.       Begin VB.Label Label1 
  326.          Alignment       =   1  'Right Justify
  327.          AutoSize        =   -1  'True
  328.          BackStyle       =   0  'Transparent
  329.          Caption         =   "+"
  330.          ForeColor       =   &H00800000&
  331.          Height          =   195
  332.          Index           =   2
  333.          Left            =   1725
  334.          TabIndex        =   17
  335.          Top             =   480
  336.          Width           =   90
  337.       End
  338.       Begin VB.Label Label1 
  339.          Alignment       =   1  'Right Justify
  340.          BackStyle       =   0  'Transparent
  341.          Caption         =   "Paper Grade"
  342.          ForeColor       =   &H00800000&
  343.          Height          =   255
  344.          Index           =   1
  345.          Left            =   60
  346.          TabIndex        =   16
  347.          Top             =   480
  348.          Width           =   1005
  349.       End
  350.       Begin VB.Label Label1 
  351.          Alignment       =   1  'Right Justify
  352.          BackStyle       =   0  'Transparent
  353.          Caption         =   "Picture Colors"
  354.          ForeColor       =   &H00800000&
  355.          Height          =   255
  356.          Index           =   0
  357.          Left            =   60
  358.          TabIndex        =   15
  359.          Top             =   270
  360.          Width           =   1005
  361.       End
  362.       Begin VB.Label Label1 
  363.          Alignment       =   1  'Right Justify
  364.          AutoSize        =   -1  'True
  365.          BackStyle       =   0  'Transparent
  366.          Caption         =   "___________________"
  367.          ForeColor       =   &H00800000&
  368.          Height          =   195
  369.          Index           =   3
  370.          Left            =   105
  371.          TabIndex        =   18
  372.          Top             =   540
  373.          Width           =   1710
  374.       End
  375.    End
  376. Attribute VB_Name = "frmCogs"
  377. Attribute VB_GlobalNameSpace = False
  378. Attribute VB_Creatable = False
  379. Attribute VB_PredeclaredId = True
  380. Attribute VB_Exposed = False
  381. Option Explicit
  382. Dim lRetVal As Long
  383. ' These variables store the current COGS values selected by the user.
  384. Dim cBindingCost As Currency
  385. Dim cPicture As Currency
  386. Dim cPaperGrade As Currency
  387. Dim lngNumPages As Long
  388. Dim strBinding As String
  389. Dim strPicture As String
  390. Dim strPaper As String
  391. Dim acurBindingCost(1) As Currency
  392. Dim acurPictureCost(1) As Currency
  393. Dim acurPaperCost(3) As Currency
  394. Dim acurCogs(5) As Currency
  395. Private Sub optPicColor_Click(Index As Integer)
  396. If Index = 0 Then
  397.   ' Black & white
  398.   strPicture = "BW"
  399.   ' Color
  400.   strPicture = "Color"
  401. End If
  402. acurCogs(0) = acurPictureCost(Index)
  403. lblCost(0).Caption = Format$(acurCogs(0), "#.0000")
  404. CalcUnitCost
  405. End Sub
  406. Private Sub Command1_Click(Index As Integer)
  407.   Dim sHelpString As String
  408.   Select Case Index
  409.     Case 0  ' Save
  410.       frmRevenue.txtRevParm(0).Text = strBinding & ", " & strPicture & ", " & strPaper
  411.       frmRevenue.txtRevParm(0).Tag = lblCost(6).Caption
  412.       Unload Me
  413.       
  414.     Case 1  ' Help
  415.       sHelpString = "Select the desired Binding Type, Picture Type, and Paper Quality." & vbCrLf & _
  416.                     "Click <Save> to save these values and return to the Book Revenue form." & vbCrLf & _
  417.                     "Click <Cancel> to discard values and return to the Book Revenue form."
  418.                     
  419.       lRetVal = MsgBox(prompt:=sHelpString, Title:="COGS Help", Buttons:=vbInformation)
  420.       
  421.     Case 2  'Close
  422.       Unload Me
  423.       
  424.  End Select
  425.       
  426. End Sub
  427. Sub CalcUnitCost()
  428.   Dim curTemp As Currency
  429.   curTemp = acurCogs(0) + acurCogs(1)
  430.   lblCost(2).Caption = Format$(curTemp, "#.0000")
  431.   curTemp = curTemp * lngNumPages
  432.   lblCost(4).Caption = Format$(curTemp, "#.0000")
  433.   curTemp = curTemp + acurCogs(5)
  434.   lblCost(6).Caption = Format$(curTemp, "#.0000")
  435. End Sub
  436. Function GetCOGS() As Integer
  437.   Dim fld As Field
  438.   Dim strSQL As String
  439.   On Error GoTo GetCOGSError
  440.   goStatusPanel.Text = "Fetching COGS numbers..."
  441.   strSQL = "SELECT * FROM COGS"
  442.            
  443.   Set gSn = gDB.OpenRecordset(strSQL, dbOpenSnapshot, dbForwardOnly)
  444.   acurBindingCost(0) = gSn.Fields("HardCover")
  445.   acurBindingCost(1) = gSn.Fields("PaperBack")
  446.   acurPictureCost(0) = gSn.Fields("BlackWhite")
  447.   acurPictureCost(1) = gSn.Fields("Color")
  448.   acurPaperCost(0) = gSn.Fields("Grade1")
  449.   acurPaperCost(1) = gSn.Fields("Grade2")
  450.   acurPaperCost(2) = gSn.Fields("Grade3")
  451.   acurPaperCost(3) = gSn.Fields("Grade4")
  452.   gSn.Close
  453.   GetCOGS = True
  454.   Exit Function
  455. GetCOGSError:
  456.   If IsObject(gSn) Then gSn.Close
  457.   GetCOGS = False
  458. End Function
  459. Public Function GetBookPages(strTitle As String) As Long
  460. Dim strSQL As String
  461. Static strOldTitle As String
  462. Static lngPages As Long
  463. On Error GoTo GetBookPagesError
  464. If strTitle <> strOldTitle Then
  465.   goStatusPanel.Text = "Retrieving page count for " & strTitle & "..."
  466.   strSQL = "SELECT Titles.Pages " & _
  467.            "FROM Titles " & _
  468.            "WHERE ((Titles.Title=" & Chr$(34) & Trim$(strTitle) & Chr$(34) & "));"
  469.   Set gSn = gDB.OpenRecordset(strSQL, dbOpenSnapshot, dbForwardOnly)
  470.   lngPages = gSn.Fields("Pages")
  471.   strOldTitle = strTitle
  472.   gSn.Close
  473.   goStatusPanel.Text = "Using cached pagecount."
  474. End If
  475. GetBookPages = lngPages
  476. Exit Function
  477. GetBookPagesError:
  478.   If IsObject(gSn) Then gSn.Close
  479.   GetBookPages = False
  480.   MsgBox Error$ & Str$(Err), vbCritical, "GetBookPages Error"
  481. End Function
  482. Private Sub Form_Load()
  483.   Me.Left = (Screen.Width - Me.Width) / 2
  484.   Me.Top = (Screen.Height - Me.Height) / 2
  485.   Me.Show
  486.   DoEvents
  487.   lngNumPages = GetBookPages(frmRevenue.cboBooks.Text)
  488.   lRetVal = GetCOGS
  489.   lblCost(0).Caption = Format$(acurPictureCost(0), "#.0000")
  490.   acurCogs(0) = acurPictureCost(0)
  491.   lblCost(1).Caption = Format$(acurPaperCost(0), "#.0000")
  492.   acurCogs(1) = acurPaperCost(0)
  493.   lblCost(3).Caption = Str$(lngNumPages)
  494.   lblCost(5).Caption = Format$(acurBindingCost(0), "#.0000")
  495.   acurCogs(5) = acurBindingCost(0)
  496.   strBinding = "Hard"
  497.   strPicture = "BW"
  498.   strPaper = "1"
  499.   CalcUnitCost
  500.   DoEvents
  501. End Sub
  502. Private Sub optBinding_Click(Index As Integer)
  503.   If Index = 0 Then
  504.     strBinding = "Hard"
  505.   Else
  506.     strBinding = "Paper"
  507.   End If
  508.   acurCogs(5) = acurBindingCost(Index)
  509.   lblCost(5).Caption = Format$(acurCogs(5), "#.0000")
  510.   If optPaperGrade(0).Value Then
  511.     optPaperGrade_Click (0)
  512.   ElseIf optPaperGrade(0).Value Then
  513.     optPaperGrade_Click (1)
  514.   ElseIf optPaperGrade(2).Value Then
  515.     optPaperGrade_Click (2)
  516.   Else
  517.     optPaperGrade_Click (3)
  518.   End If
  519.   CalcUnitCost
  520. End Sub
  521. Private Sub optPaperGrade_Click(Index As Integer)
  522.   Select Case Index
  523.     Case 0
  524.       strPaper = "1"
  525.       
  526.     Case 1
  527.       strPaper = "2"
  528.       
  529.     Case 2
  530.       strPaper = "3"
  531.     Case 3
  532.       strPaper = "4"
  533.       
  534.   End Select
  535.   If optBinding(1).Value = True Then
  536.     acurCogs(1) = acurPaperCost(Index) * 0.5
  537.       
  538.   Else
  539.     acurCogs(1) = acurPaperCost(Index)
  540.   End If
  541.   lblCost(1).Caption = Format$(acurCogs(1), "#.0000")
  542.   CalcUnitCost
  543. End Sub
  544.